<!DOCTYPE html>
<html>
<head>
    <title>Weiran Embeded Device Applications</title>
    <meta charset="utf-8" />
    <script src="../../jpp/jquery/jquery-1.7.2.min.js"></script>
    <script src="../../jpp/soundmanager/soundmanager2.min.js"></script>
    <script src="../../jpp/socket.io/io-0.9.6.min.js"></script>
    <script src="http://openlayers.org/api/2.12/OpenLayers.js"></script>
    <script src="../../jpp/openlayers/plugins/weolstk-0.4.min.js"></script>
    <script src="../../jpp/tian/tian-1.0.min.js"></script>
    <style>html, body, #weiran {margin: 0; width: 100%; height: 100%;} </style>
<script>
    var mms, webcam, gt02a, gt02b;
    function addDevices(os) {
        mms = new Tian.Device({
            os: os,
            id: 'mms',
            key: 'mms-key',
            title: 'MMS',
            lonlat: [120.0, 30.0],
            icon: 'devices/mms/icon.png', 
            page: 'devices/mms/index.html',
            alarm: 'devices/mms/alarm.mp3',
            width: 540,
            height: 300,
            camera: 'mms://www.onedir.com/Cam1'
        });
        
        webcam = new Tian.Device({
            os: os,
            id: 'webcam',
            key: 'webcam-key',
            title: 'Webcam',
            lonlat: [139.2599, 37.4105],
            icon: 'devices/webcam/icon.png', 
            page: 'devices/webcam/index.html',
            alarm: 'devices/webcam/alarm.mp3',
            width: 540,
            height: 300,
            camera: 'http://iozoonc5.city.miyazaki.miyazaki.jp/CgiStart?page=Single&Language=12'
        });
        
        gt02a = new Tian.Device({
            os: os,
            id: '4fe174a3692d8b6009000025',
            key: '255cc9ce67c1db4a562e37c20fac58a6',
            title: 'GT02A',
            lonlat: [120.0, 31.0],
            icon: 'devices/gt02a/icon.png', 
            page: 'devices/gt02a/index.html',
            alarm: 'devices/gt02a/alarm.mp3',
            width: 540,
            height: 300,
            dragable: true,
            host: '127.0.0.1:2013',
            imei: '353419036592322'
        });
        
        /*var imeib = '123456789012345';
        gt02b = new Tian.Device({
            os: os,
            id: 'gt02b',
            key: Tian.md5(imeib),
            title: 'GT02A-b',
            lonlat: [120.0, 31.0],
            icon: 'devices/gt02a/icon.png', 
            page: 'devices/gt02a/index.html',
            alarm: 'devices/gt02a/alarm.mp3',
            width: 540,
            height: 300,
            dragable: true,
            host: 'http://www.fanghuanweiran.com:2013',
            imei: imeib
        });*/
        
        os.devices.addFeatures([mms.feature, webcam.feature, gt02a.feature/*, gt02b.feature*/]);
    }
    
    function addApps(os) {
        // internal
        os.getMainPanel().addApp(new Tian.App({
            title: {'en': 'Account', 'zh-CN': '用户'},
            icon: 'apps/account/icon.png', 
            page: 'apps/account/index.html',
            width: 540,
            height: 300
        }));
        os.getMainPanel().addApp(new Tian.App({
            title: {'en': 'Device Manager', 'zh-CN': '设备管理'},
            icon: 'apps/device/icon.png', 
            page: 'apps/device/index.html',
            width: 540,
            height: 300
        }));
        os.getMainPanel().addApp(new Tian.App({
            title: {'en': 'Notification Center', 'zh-CN': '通知中心'},
            icon: 'apps/notification/icon.png', 
            page: 'apps/notification/index.html',
            width: 540,
            height: 300
        }));
        os.getMainPanel().addApp(new Tian.App({
            title: {'en': 'Layer Switcher', 'zh-CN': '图层切换'},
            icon:'apps/layerswitcher/icon.png',
            page:'apps/layerswitcher/index.html',
            width: 240,
            height: 400
        }));
        os.getMainPanel().addApp(new Tian.App({
            title: {'en': 'iWhere', 'zh-CN': '我在哪里'},
            icon:'apps/iwhere/icon.png',
            page:'apps/iwhere/index.html',
            width: 200,
            height: 160
        }));
        os.getMainPanel().addApp(new Tian.App({
            title: {'en': 'LonLat Picker', 'zh-CN': '点取坐标'},
            icon:'apps/llpicker/icon.png',
            page:'apps/llpicker/index.html',
            width: 260,
            height: 160
        }));
        os.getMainPanel().addApp(new Tian.App({
            title: {'en': 'Measuring Tools', 'zh-CN': '测量工具'},
            icon:'apps/measure/icon.png',
            page:'apps/measure/index.html',
            width: 280,
            height: 140
        }));
        os.getMainPanel().addApp(new Tian.App({
            title: {'en': 'Cell Tracker', 'zh-CN': '基站定位'},
            icon:'apps/celltracker/icon.png',
            page:'apps/celltracker/index.html',
            width: 200,
            height: 200
        }));
        // external
        //os.getMainPanel().addApp(new Tian.App('google'));
        os.getMainPanel().addApp(new Tian.App('calculator'));
        os.getMainPanel().addApp(new Tian.App('baidu'));
        os.getMainPanel().addApp(new Tian.App('soso'));
        os.getMainPanel().addApp(new Tian.App('mango'));
        os.getMainPanel().addApp(new Tian.App('kuaidi100'));
        //os.getMainPanel().addApp(new Tian.App('qq'));
        //os.getMainPanel().addApp(new Tian.App('tudou'));
        //os.getMainPanel().addApp(new Tian.App('douban'));
    }
    
    function testDevices(os) {
        for (var i=0; i<100; i++) {
            var imeib = '1234567890' + i;
            var gt02b = new Tian.Device({
                os: os,
                id: 'gt02b_' + imeib,
                key: Tian.md5(imeib),
                title: 'GT02A-' + imeib,
                lonlat: [150*Math.random(), 80*Math.random()],
                icon: 'devices/gt02a/icon.png', 
                page: 'devices/gt02a/index.html',
                alarm: 'devices/gt02a/alarm.mp3',
                width: 540,
                height: 300,
                dragable: true,
                host: '127.0.0.1:2013',
                imei: imeib
            });
        
            os.devices.addFeatures([gt02b.feature]);
        }
    }
    
    var os;
    $(document).ready(function(){
        os = new Tian.OS('weiran', 'http://127.0.0.1:2080');
        os.themeHost = '../../fanghuanweiran/branches/theme/';
        os.boot();
        
        addDevices(os);
        addApps(os);
        //testDevices(os);
    });
</script>
</head>

<body>
<div id='weiran'></div>
</body>
</html>
